function loadFriends() {
  var req = opensocial.newDataRequest();
  req.add(req.newFetchPersonRequest('VIEWER'), 'viewer');
  req.add(req.newFetchActivitiesRequest('VIEWER_ACTIVITIES'), 'viewerActivities');
  req.send(onLoadFriends);
}

function onLoadFriends(data) {
  var viewer = data.get('viewer').getData();
  var viewerFriends = data.get('viewerActivities').getData();
  
  html = new Array();
  html.push('<ul>');
  viewerActivities.each(function(activity) {
    html.push('<li>' + activity.getField('TITLE') + "</li>");
  });
  html.push('</ul>');
  document.getElementById('activities').innerHTML = html.join('');
}

function init() {
  loadFriends();
}